/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.hogent.iii.project.client.gui.gameroom;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author jef donders
 */
public class ChatPanel extends JPanel implements ActionListener {

    private JScrollPane jScrollPane1;
    private JTextField textField;
    private JTextArea textArea;
    private GameRoomGui ouder;
    
    public ChatPanel(GameRoomGui ouder) {
        this.ouder = ouder;
        initComponents();
        textArea.setText("Welkom in de gameroom van CivBasic");
        textArea.append("\n------------------------------------------\n");
        
    }

    private void initComponents() {
        setBackground(new java.awt.Color(0, 0, 0));
        setForeground(new java.awt.Color(255, 255, 255));
        jScrollPane1 = new JScrollPane();
        textArea = new JTextArea();
        textArea.setBackground(new java.awt.Color(102, 0, 0));
        textArea.setFont(new java.awt.Font("Tahoma", 1, 11));
        textArea.setForeground(new java.awt.Color(204, 153, 0));
        
        textField = new JTextField();
        textField.setBackground(new java.awt.Color(102, 0, 0));
        textField.setFont(new java.awt.Font("Tahoma", 1, 11));
        textField.setForeground(new java.awt.Color(204, 153, 0));
        
        jScrollPane1.setViewportView(textArea);

        textField.addActionListener(this);
        
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(textField, 0, 390, Short.MAX_VALUE)
                .addComponent(jScrollPane1, 0, 502, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, 0, 100,Short.MAX_VALUE)
                .addGap(10,10,10)
                .addComponent(textField, 25, 25, 25))
        );
    }
    
    public void printText(String text){
        
        textArea.append(text);
    }

    public void actionPerformed(ActionEvent e) {
        if (!textField.getText().equalsIgnoreCase(""))
            ouder.stuurChatBericht(textField.getText());
        textField.setText("");
    }
    
    
    
}
